package model;

/**
 * Publicly accessible struct representing a single card
 */
public class Card {
	/** Numerical value of the card: A=1, K=13, Q=12, J=11, 10, 9, ..., small joker=14, big joker=15 */
	public int value; 
	/** Suit value of the card*/
	public Suit suit; 
	
	private int handx = -1;
	private int handy = -1;
	
	/** true when slightly higher */
	private boolean up = false;
	
    /** when true, yellow highlight drawn around stack */
    private boolean highlighted;
	
	
	public Card(int value, Suit suit) {
		this.value=value;
		this.suit=suit;
		this.highlighted = false;
		
		if(value<0||value>15||value>13&&suit!=Suit.JOKER)
			throw new RuntimeException("Attempting to construct an invalid card value!");
	}
	public String toString() {
		return this.value+""+this.suit;
	}
	
	public void setHandXY(int x, int y)
	{
		handx = x;
		handy = y;
	}
	
	public boolean isUp()
	{
		return up;
	}
	
	public void toggleUp()
	{
		this.up = !this.up;
		
		this.handy += this.up? -15: 15; 
	}
	
	
	public int getHandX()
	{
		return handx;
	}
	
	public int getHandY()
	{
		return handy;
	}
	
    public boolean isHighlighted()
    {
    	return this.highlighted;
    }
    
    public void highlightedTrue()
    {
    	this.highlighted = true;
    }
    
    public void highlightedFalse()
    {
    	this.highlighted = false;
    }
	
}
